#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>

using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,L,V,p[N],d[N],v[N],a[N],le[N],ri[N];pii P[N];
void solve()
{
    scanf("%d%d%d%d",&n,&m,&L,&V);
    for(int i=0;i<n;i++)scanf("%d%d%d",&d[i],&v[i],&a[i]);
    for(int i=0;i<m;i++)scanf("%d",&p[i]);
    for(int i=0;i<n;i++){
        le[i]=ri[i]=-1;int l,r;
        l=lower_bound(p,p+m,d[i])-p,r=m-1;int st=l;
        if(st==m)continue;
        if(a[i]<=0){
            if(v[i]<=V)continue;
            while(l<=r){
                int mid=(l+r)>>1;
                if(v[i]*v[i]-V*V>(p[mid]-d[i])*(-2*a[i]))
                    l=mid+1;
                else
                    r=mid-1;
            }l--;
            if(st<=l)le[i]=st,ri[i]=l;
        }else{
            if(v[i]>V){
                le[i]=st;ri[i]=m-1;
                continue;
            }
            while(l<=r){
                int mid=(l+r)>>1;
                if(V*V-v[i]*v[i]>=(p[mid]-d[i])*(2*a[i]))
                    l=mid+1;
                else
                    r=mid-1;
            }if(l!=m)le[i]=l,ri[i]=m-1;
        }
    }
    int ans1=0,ans2=0,cnt=0;
    for(int i=0;i<n;i++)
        if(le[i]!=-1)ans1++,P[cnt++]=mp(le[i],ri[i]);
    sort(P,P+cnt);int cur=mod;
    for(int i=0;i<cnt;i++){
        if(P[i].F<=cur)cur=min(cur,P[i].S);
        else ans2++,cur=P[i].S;
    }if(cur==mod)ans2=0;else ans2++;
    ans2=m-ans2;
    printf("%d %d\n",ans1,ans2);
    return;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--)solve();
    return 0;
}